home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctj0987.arc
/
PUSHPOP.C
< prev
next >
Wrap
Text File
|
1987-07-02
|
2KB
|
89 lines
/*
* PUSHPOP -- PC Tech Journal Laser Printer Graphics Box Test
*
* Version 1.0
*
* Copyright (c) 1987, Ziff Communications Company
* Program by: Rainer McCown
*
* This routine uses a simple macro to draw a graphics box at 22
* positions across the page. A push is executed after the first 21
* boxes are drawn. 21 pops followed by the numbers 01 thru 21
* respectively are then printed.
*/
#include "string.h"
#define STD_OUT 1
extern void sndl(char [], int),
snd (char []),
setbinary(int);
/******************************* MAIN *******************************/
void main()
{
int cnt;
char *txt, *p;
/* Change STD_OUT to binary mode to avoid
converting LFs to CR,LF and to avoid
stopping on EOFs
*/
setbinary(STD_OUT);
/* Initialize the printer */
snd("\x1BE"); /* Reset the printer */
snd("\x1B&l0O"); /* Portrait mode */
/* Send macro defn to printer */
snd("\x1B&f1Y\x1B&f0X"); /* Start macro #1 definition */
snd("\x1B*p-95Y\x1B*p-10X"); /* Position offset */
snd("\x1B*t150R"); /* Resolution = 150dpi */
snd("\x1B*r1A\x0D\x0A"); /* Start raster graphic */
/* Send the bit pattern for a box */
snd("\x1B*b5W\xFF\xFF\xFF\xFF\xFF"); /* Top */
for (cnt = 0; cnt < 31; cnt++)
sndl("\x1B*b5W\x80\x00\x00\x00\x01", 10); /* Mid */
snd("\x1B*b5W\xFF\xFF\xFF\xFF\xFF"); /* Bottom */
/* End the box and the macro */
snd("\x1B*rB\x1B&f1X");
/* Position cursor, push location, execute macro */
txt = "\x1B*p??00X\x1B*p100Y\x1B&f0S\x1B&f1y2X";
p = strchr(txt, '?'); /* Point to fill location */
for (cnt = 1; cnt <= 22; cnt++)
{
p[0] = '0' + cnt/10; /* Format 10s digit */
p[1] = '0' + cnt%10; /* Format 1s digit */
snd(txt); /* Send to the printer */
}
/* Pop location, write numbers */
txt = "\x0D\x0A\x1B&f1S??";
p = strchr(txt, '?'); /* Point to fill location */
for (cnt = 1; cnt <= 21; cnt++)
{
p[0] = '0' + cnt/10; /* Format 10s digit */
p[1] = '0' + cnt%10; /* Format 1s digit */
snd(txt); /* Send to the printer */
}
/* Eject page */
snd("\f");
} /* End MAIN */